﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace MedicalManagementSystem.Utils
{
    public class MenuLink
    {
        public MenuLink(string name, string action, string controller)
        {
            Name = name;
            Action = action;
            Controller = controller;
        }

        public string Name { get; set; }
        public string Action { get; set; }
        public string Controller { get; set; }
    }

    public class Menu
    {
        static Dictionary<string, MenuLink> menu = new Dictionary<string,MenuLink>();
        static public string ID = "";
        static public string Title 
        {
            get { return menu[ID].Name; }
        }


        static Menu()
        {
            menu["patient,createChart"] = new MenuLink("Завести карту","Create","PatientChart");
            menu["patient,add"] = new MenuLink("Добавить пациента", "Create", "Patient");
            menu["patient,active"] = new MenuLink("Текущие пациенты", "Index", "Patient");
            menu["patient,archive"] = new MenuLink("Архив", "Archive", "Patient");
            
            menu["adm,diagnos"] = new MenuLink("Диагнозы", "Index", "DiagnosBloc");
            menu["adm,doctor"] = new MenuLink("Врачи", "Index", "Doctor");
            menu["adm,district"] = new MenuLink("Районы", "Index", "District");
            menu["adm,region"] = new MenuLink("Области", "Index", "Region");
            menu["adm,hospital"] = new MenuLink("Больницы", "Index", "Hospital");

            menu["anal,statReport"] = new MenuLink("Государственная статистическая отчетность", "StatisticsReport", "Reports");
            
        }

        public static string getMenu(HtmlHelper html, string mType)
        {
            var builder = new TagBuilder("ul");
            builder.AddCssClass("left_menu");
            foreach (var item in menu)
            {
                var menuType = item.Key.Split(',');
                if (menuType[0] != mType) continue;
                var liBuilder = new TagBuilder("li");
                liBuilder.InnerHtml = html.ActionLink(item.Value.Name, item.Value.Action, item.Value.Controller).ToString();
                if (ID == item.Key)
                {
                    liBuilder.AddCssClass("selected");
                }
                builder.InnerHtml += liBuilder.ToString();
            }
            return builder.ToString();
        }
    }
}
